package br.com.tamagotchi.controle;

import br.com.tamagotchi.modelo.Brincar;
import br.com.tamagotchi.modelo.Tamagotchi;

public class FelicidadeThread implements Runnable {

	Tamagotchi tamagotchi;

	public FelicidadeThread(Tamagotchi tamagotchi) {
		this.tamagotchi = tamagotchi;
	}

	@Override
	public void run() {
		while (true) {
			try {
				if (!(tamagotchi.getIatividade() instanceof Brincar) || (tamagotchi.getIatividade() != null)) {
					Thread.sleep(tamagotchi.getTempoSleep() * 1000);
					if (tamagotchi.getFelicidade() > 0)
						tamagotchi.countDownFelicidade();
				}
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

}
